var SITE_TIP_OBJ = function($) {
	function Site_tip() {
		this._id = null;
		this.isAnimal = false;
		this.timer;
		if($("#site-loading-tip").length<=0)
		{
			var loadingTpl = '<div class="site-loading-tip" id="site-loading-tip"><i class="icon-sm-loading"></i><p></p></div>';
			$("body").prepend(loadingTpl);
		}
		if($("#site-tip").length<=0)
		{
			var tipTpl = '<div class="site-loading-tip" id="site-tip"><i class="icon-warning"></i><p></p><a class="close">关闭</a></div>';
			$("body").prepend(tipTpl);
		}

	}

	Site_tip.prototype.show = function() {
		$("#site-loading-tip").hide();
		$("#site-tip").show();
		if(this.isAnimal){
			this._hideAnimal();
		}
	}

	Site_tip.prototype.hide = function() {
		clearTimeout(this._id);
		$("#site-tip").hide();
	}

	Site_tip.prototype._hideAnimal = function() {
		clearTimeout(this._id);
		/*this._id= setTimeout(function(){
		 $("#site-tip").hide();
		 }, 5000);*/
	}

	Site_tip.prototype._change_css = function() {
		/*$("#site-tip").css("opacity", "0");
		 this.show();
		 var realWidth = parseInt($("#site-tip span").width());
		 realWidth +=parseInt($("#site-tip .text").css("margin-left"));
		 realWidth +=parseInt($("#site-tip .text").css("margin-right"));
		 $("#site-tip span").parent().width($("#site-tip span").width());

		 if ($("#site-tip .imgBox-outer").css("display") != "none") {
		 $("#site-tip span").parent().css("float","left");
		 realWidth += parseInt($("#site-tip .imgBox-outer").width());
		 realWidth += parseInt($("#site-tip .imgBox-outer").css("margin-right"));
		 }else{
		 $("#site-tip span").parent().css("float","none");
		 $("#site-tip span").parent().css("margin","0 auto");
		 }

		 if (realWidth < 150) {
		 realWidth = 150;
		 }

		 $("#site-tip .panel-inner").width(realWidth);
		 $("#site-tip .text").width(realWidth-44);

		 $("#site-tip .panel-inner").css("margin", "0 auto");
		 $("#site-tip").css("opacity", "1");*/
	}

	Site_tip.prototype.setContent = function(msg,showClose,autoClose,sec) {
		if(this.timer)
		{
			//先清除上一次timer
			clearTimeout(this.timer);
		}
		sec = sec || 3000;
		$("#site-loading-tip").hide();
		var box = $("#site-tip");
		box.hide();
		if(!showClose){
			/*$("#site-tip").find("span").html(msg+"&nbsp;&nbsp; <a id='site-tip-del' href='#' class='inner-tip'>关闭</a>");
			 var id = this._id;
			 var hideFun = this.hide;
			 $("#site-tip").off();
			 $("#site-tip").on("click",function(e){
			 e.stopPropagation();
			 })
			 $("#site-tip").on("click","#site-tip-del",function(e){
			 hideFun();
			 })*/
			box.find(".close").hide();

		}else{

			box.find(".close").show().click(function(){
				box.hide();
			});
		}

		var icon = box.find("i");
		if(showClose){
			icon.show();
		}else{
			icon.hide();
		}
		if(!showClose||autoClose){
			this.timer=setTimeout(function(){
				box.hide();
			},sec);
		}
		box.find("p").html(msg);
		box.show().css("marginLeft",-box.outerWidth()/2);
		//this._change_css();
	}
	Site_tip.prototype.loadingMsg = function(msg,close)
	{
		close = close || false;
		var me = this;
		//关闭其他提示
		me.hide();
		var box = $("#site-loading-tip");
		if(close)
		{
			box.hide();
		}
		else
		{
			msg = msg || "正在操作";
			msg +="...";
			box.find("p").html(msg);
			box.show().css("marginLeft",-box.outerWidth()/2);
		}
	};
	return Site_tip;
};
if(typeof(define)!="undefined")
{
	define([ "jquery"], SITE_TIP_OBJ );
}
else
{

	$.site_tip = SITE_TIP_OBJ($);
}
